package com.culturalCenter.dataCenter.service.impl.user;

import com.culturalCenter.dataCenter.entity.user.UserActivity;
import com.culturalCenter.dataCenter.mapper.user.UserActivityMapper;
import com.culturalCenter.dataCenter.service.user.UserActivityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/****
 * @Author:
 * @Description:UserActivity业务层接口实现类
 * @Date
 *****/
@Service
public class UserActivityServiceImpl implements UserActivityService {

    @Resource
    private UserActivityMapper userActivityMapper;

    @Override
    public PageInfo<UserActivity> findPage(int page, int size) {
        return PageHelper.startPage(page, size).doSelectPageInfo(() -> userActivityMapper.findPageAll());
    }

    @Override
    public Integer delete(String id) {
        return userActivityMapper.deleteById(id);
    }

    @Override
    public Integer update(UserActivity userActivity) {
        return userActivityMapper.update(userActivity);
    }

    @Override
    public Integer add(UserActivity userActivity) {
        return userActivityMapper.insert(userActivity);
    }

    @Override
    public UserActivity findById(String id) {
        return userActivityMapper.queryById(id);
    }

    @Override
    public List<UserActivity> findAll(UserActivity userActivity) {
        return (List<UserActivity>) userActivityMapper.queryAll(userActivity);
    }

    @Override
    public PageInfo<UserActivity> findActivityList(String userId, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<>(userActivityMapper.queryByUserId(userId));
    }

}
